package com.ruoyi.tsjData.service.impl;

import java.util.List;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ProcessPictureUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.tsjData.domain.result.DataTshjJxResult;
import com.ruoyi.tsjData.mapper.DataTshjJxResultMapper;
import com.ruoyi.tsjData.service.IDataTshjJxResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 提升机-间隙测试结果Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-07
 */
@Service
public class DataTshjJxResultServiceImpl implements IDataTshjJxResultService
{
    @Autowired(required = false)
    private DataTshjJxResultMapper dataTshjJxResultMapper;

    /**
     * 查询提升机-间隙测试结果
     * 
     * @param jxResultId 提升机-间隙测试结果主键
     * @return 提升机-间隙测试结果
     */
    @Override
    public DataTshjJxResult selectDataTshjJxResultByJxResultId(Long jxResultId)
    {
        return dataTshjJxResultMapper.selectDataTshjJxResultByJxResultId(jxResultId);
    }

    /**
     * 查询提升机-间隙测试结果列表
     * 
     * @param dataTshjJxResult 提升机-间隙测试结果
     * @return 提升机-间隙测试结果
     */
    @Override
    public List<DataTshjJxResult> selectDataTshjJxResultList(DataTshjJxResult dataTshjJxResult)
    {
        return dataTshjJxResultMapper.selectDataTshjJxResultList(dataTshjJxResult);
    }

    /**
     * 任务id查询间隙结果
     * @param dataTaskId
     * @return
     */
    @Override
    public List<DataTshjJxResult> selectDataTshjJxResultByDataTaskId(Long dataTaskId, Long dataResultId) {
        return dataTshjJxResultMapper.selectDataTshjJxResultByDataTaskId(dataTaskId, dataResultId);
    }

    /**
     * 新增提升机-间隙测试结果
     * 
     * @param dataTshjJxResult 提升机-间隙测试结果
     * @return 结果
     */
    @Override
    public int insertDataTshjJxResult(DataTshjJxResult dataTshjJxResult)
    {
        dataTshjJxResult.setCreateTime(DateUtils.getNowDate());
        if(StringUtils.isNotEmpty(dataTshjJxResult.getWySvg())) {
            //间隙图路径
            String rootPath = RuoYiConfig.getProfile() + RuoYiConfig.getChartPath() + "/";
            String jxImg = System.currentTimeMillis() + "-间隙图.png";
            //svg转png
            ProcessPictureUtils.convertToPng(dataTshjJxResult.getWySvg(), rootPath + dataTshjJxResult.getDataTaskId() + "/" + jxImg);
            dataTshjJxResult.setWyImg("/profile/chartPath/" + dataTshjJxResult.getDataTaskId() + "/" + jxImg);
        }
        return dataTshjJxResultMapper.insertDataTshjJxResult(dataTshjJxResult);
    }

    /**
     * 修改提升机-间隙测试结果
     * 
     * @param dataTshjJxResult 提升机-间隙测试结果
     * @return 结果
     */
    @Override
    public int updateDataTshjJxResult(DataTshjJxResult dataTshjJxResult)
    {
        dataTshjJxResult.setUpdateTime(DateUtils.getNowDate());
        return dataTshjJxResultMapper.updateDataTshjJxResult(dataTshjJxResult);
    }

    /**
     * 批量删除提升机-间隙测试结果
     * 
     * @param jxResultIds 需要删除的提升机-间隙测试结果主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjJxResultByJxResultIds(Long[] jxResultIds)
    {
        return dataTshjJxResultMapper.deleteDataTshjJxResultByJxResultIds(jxResultIds);
    }

    /**
     * 删除提升机-间隙测试结果信息
     * 
     * @param jxResultId 提升机-间隙测试结果主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjJxResultByJxResultId(Long jxResultId)
    {
        return dataTshjJxResultMapper.deleteDataTshjJxResultByJxResultId(jxResultId);
    }
}
